<html>
<head>
	<title>芭蕉花管理平台-众筹单详情</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<link rel="SHORTCUT ICON" href="/img/favicon.ico">
	<script type="text/javascript">
		var pathname = window.location.pathname;
		if (pathname != "/mobile/home.html") {
			location.href = '/';
		}
	</script>
	<style type="text/css">
		.btn {appearance: none; -moz-appearance: none; -webkit-appearance: none;}
		.tab-content {margin-top: 10px; margin-bottom: 10px;}
		.info-item .title {display: inline-block; font-size: .8rem; color: #999; width: 6rem;}
		.info-item .content {display: inline-block; font-size: .8rem; word-break: break-all;}
		.info-item .content .bill-img {width: 4rem; height: 4rem; padding: 2px;}
		.info-item .content .status {padding: .5em;}
		.money-item {padding-top: .5rem; border-bottom: 1px solid rgba(0,0,0,.125);}
		.money-item .account {display: inline-block; color: #666;}
		.money-item .money {display: inline-block; text-align: right; float: right; font-weight: bold;}
		.money-item .time {font-size: .6rem; color: #aaa; text-align: right;}
		#dataInfo {margin-top: .5rem; font-size: .6rem; color: #777; text-align: right;}
		#pageList {margin-top: 1.25rem;}
		#pageList nav {display: inline-block;}
		#pageList .page-link:hover {z-index: 2; color: #007bff; text-decoration: none; background-color: #fff; border-color: #dee2e6;}
		#pageList .page-link:active {z-index: 2; color: #0056b3; text-decoration: none; background-color: #e9ecef; border-color: #dee2e6;}
		#pageList .page-link:focus {box-shadow: none;}
	</style>
</head>
<body>
	<div class="container">
		<nav aria-label="breadcrumb">
			<ol class="breadcrumb">
				<li class="breadcrumb-item"><a href="#" onclick="goCrowfundList();return false;"><i class="fa fa-chevron-left"></i><span style="padding-left: 10px;">用户众筹列表</span></a></li>
				<li class="breadcrumb-item active" aria-current="page">用户众筹详情</li>
			</ol>
		</nav>
		<nav>
			<div class="nav nav-tabs" id="nav-tab" role="tablist">
				<a class="nav-item nav-link active" id="nav-tab-detail" data-toggle="tab" href="#nav-detail" role="tab" aria-controls="nav-detail" aria-selected="true">众筹基本信息</a>
				<a class="nav-item nav-link" id="nav-tab-money-list" data-toggle="tab" href="#nav-money-list" role="tab" aria-controls="nav-money-list" aria-selected="false">筹款记录</a>
			</div>
		</nav>
		<div class="tab-content" id="nav-tabContent">
			<div class="tab-pane fade show active" id="nav-detail" role="tabpanel" aria-labelledby="nav-tab-detail">
				<div class="card">
					<div class="card-body">
						<div class="info-item">
							<div class="title">众筹标题</div>
							<div class="content" id="infoTitle"></div>
						</div>
						<div class="info-item">
							<div class="title">众筹类型</div>
							<div class="content" id="infoType"></div>
						</div>
						<div class="info-item">
							<div class="title">筹集金额</div>
							<div class="content" id="infoTargetMoney"></div>
						</div>
						<div class="info-item">
							<div class="title">已筹金额</div>
							<div class="content" id="infoCurrentMoney"></div>
						</div>
						<div class="info-item">
							<div class="title">发单银行卡</div>
							<div class="content" id="infoBankCard"></div>
						</div>
						<div class="info-item">
							<div class="title">收款银行卡</div>
							<div class="content" id="infoReceiptBankCard"></div>
						</div>
						<div class="info-item">
							<div class="title">用户昵称</div>
							<div class="content" id="infoUserName"></div>
						</div>
						<div class="info-item">
							<div class="title">用户账号</div>
							<div class="content" id="infoAccount"></div>
						</div>
						<div class="info-item">
							<div class="title">账单金额</div>
							<div class="content" id="infoBillMoney"></div>
						</div>
						<div class="info-item">
							<div class="title">账单图片</div>
							<div class="content" id="infoBillImg"></div>
						</div>
						<div class="info-item">
							<div class="title">账单类型</div>
							<div class="content" id="infoBillType"></div>
						</div>
						<div class="info-item">
							<div class="title">开始时间</div>
							<div class="content" id="infoStartTime"></div>
						</div>
						<div class="info-item">
							<div class="title">结束时间</div>
							<div class="content" id="infoEndTime"></div>
						</div>
						<div class="info-item">
							<div class="title">状态</div>
							<div class="content" id="infoStatus"></div>
						</div>
						<div class="info-item">
							<div class="title">打款订单号</div>
							<div class="content" id="infoOrderNum"></div>
						</div>
						<div class="info-item">
							<div class="title">服务费</div>
							<div class="content" id="infoServiceMoney"></div>
						</div>
						<div class="info-item">
							<div class="title">筹集原因</div>
							<div class="content" id="infoReason"></div>
						</div>
						<div class="info-item">
							<div class="title">信用扣分</div>
							<div class="content" id="infoCreditPoint"></div>
						</div>
						<div class="info-item">
							<div class="title">扣分原因</div>
							<div class="content" id="infoCreditReason"></div>
						</div>
						<div class="info-item">
							<div class="title">驳回原因</div>
							<div class="content" id="infoRejectReason"></div>
						</div>
					</div>
				</div>
			</div>
			<div class="tab-pane fade" id="nav-money-list" role="tabpanel" aria-labelledby="nav-tab-money-list">

				<div class="row" id="searchBox">
					<div class="col-sm-6 col-md-4 col-lg-3 col-xl-2">
						<div class="form-group">
							<input type="text" id="searchCrowd" class="form-control" placeholder="输入用户账号/互助金额搜索"/>
						</div>
					</div>
					<div class="col-sm-6 col-md-4 col-lg-3 col-xl-2">
						<div class="form-group">
							<button type="button" onclick="search();"  class="btn btn-block btn-primary">搜索</button>
						</div>
					</div>
				</div>

				<div id="crowdfundMoneyList">
				</div>
				<div id="dataInfo">
				</div>

				<div class="row" id="pageList">
					<div class="col-xl-12 text-center">
						<nav aria-label="...">
							<ul class="pagination">
								<li class="page-item previous disabled">
									<a class="page-link" href="#" onclick="goPrevious();return false;">上一页</a>
								</li>
								<li class="page-item next disabled">
									<a class="page-link" href="#" onclick="goNext();return false;">下一页</a>
								</li>
							</ul>
						</nav>
					</div>
				</div>
			</div>
		</div>
	</div>

<!-- page script -->
<script>
	// 取得通过html传递的参数
	var listPage = 1;
	var paramListPage = getHtmlParams("page");
	if (paramListPage != null) {
		listPage = paramListPage;
	}
	var crdId = 0;
	var paramCrdId = getHtmlParams("crdId");
	if (paramCrdId != null) {
		crdId = paramCrdId;
	}
	var searchSort = "";
	var paramSearchSort = getHtmlParams("searchSort");
	if (paramSearchSort != null) {
		searchSort = paramSearchSort;
	}
	var searchStatus = "";
	var paramSearchStatus = getHtmlParams("searchStatus");
	if (paramSearchStatus != null) {
		searchStatus = paramSearchStatus;
	}
	var searchCardType = "";
	var paramSearchCardType = getHtmlParams("searchCardType");
	if (paramSearchCardType != null) {
		searchCardType = paramSearchCardType;
	}
	var searchCrowd = "";
	var paramSearchCrowd = getHtmlParams("searchCrowd");
	if (paramSearchCrowd != null) {
		searchCrowd = paramSearchCrowd;
	}
	var searchType = "";
	var paramSearchType = getHtmlParams("searchType");
	if (paramSearchType != null) {
		searchType = paramSearchType;
	}
	// 取后清空
	clearHtmlParams();

	var maxCount = 10;
	var totalPages = 0;
	var page = 1;

	//获取众筹单id
	$(document).ready(function() {
		//加载数据
		getCrowdfundDetail();
		getCrowdfundMoneyList();
	});

	function goCrowfundList() {
		let url = "/mobile/pages/crowdfund/crowdfundList.html";
		let params = {
				"htmlParams": [
						{
							"key" : "page",
							"value" : listPage
						},
						{
							"key" : "searchSort",
							"value" : searchSort
						},
						{
							"key" : "searchStatus",
							"value" : searchStatus
						},
						{
							"key" : "searchCardType",
							"value" : searchCardType
						},
						{
							"key" : "searchCrowd",
							"value" : searchCrowd
						},
						{
							"key" : "searchType",
							"value" : searchType
						}
				]
		}
		getHtml(url, params);
	}

	function getCrowdfundDetail() {
		let url = "/crowdfund/getCrowdfundById";
		let params = {
				"id" : crdId
		}
		getMapData(url, params, function(data, result) {
			if (result == "success") {
				let crowdfund = data.crowdfund;
				let type = crowdfund.type;
				let typeStr = "";
				if(type == 1){
					typeStr = "江湖救急"
				} else if(type == 2){
					typeStr = "还房贷";
				} else if(type == 3){
					typeStr = "还车贷";
				} else if(type == 4){
					typeStr = "还信用卡";
				} else if(type == 5){
					typeStr = "求助";
				}
				let imgArray = crowdfund.img.split("$");
				let imgHtml = "";
				for (let i = 0; i < imgArray.length; i++) {
					let imgUrl = imgArray[i];
					imgHtml += '<img class="bill-img" src="' + imgUrl + '" onclick="maxImg(' + "'" + imgUrl + "'" + ",'" + '账单' + "'" + ')" alt="账单">';
				}
				let billType = crowdfund.billType;
				let billTypeStr = "";
				if (billType == 1) {
					billTypeStr = "需好友担保";
				} else {
					billTypeStr = "系统分配的";
				}
				let status = crowdfund.status;
				let statusHtml = "";
				if (status == 0) {
					statusHtml += '<span class="status badge badge-primary">待审核</span>';
				} else if (status == 1) {
					statusHtml += '<span class="status badge badge-success">进行中</span>';
				} else if (status == 2) {
					statusHtml += '<span class="status badge badge-warning">付款中</span>';
				} else if (status == 3) {
					statusHtml += '<span class="status badge badge-secondary">已完成</span>';
				} else if (status == 4) {
					statusHtml += '<span class="status badge badge-success">进行中(已扣分)</span>';
				} else if (status == 5) {
					statusHtml += '<span class="status badge badge-danger">已驳回</span>';
				} else if (status == 6) {
					statusHtml += '<span class="status badge badge-secondary">已失效</span>';
				} else if (status == 21) {
					statusHtml += '<span class="status badge badge-warning">付款中(暂停付款)</span>';
				} else if (status == 22) {
					statusHtml += '<span class="status badge badge-success">进行中(已证明)</span>';
				}
				$("#infoTitle").html(crowdfund.title);
				$("#infoType").html(typeStr);
				$("#infoTargetMoney").html(crowdfund.targetMoney);
				$("#infoCurrentMoney").html(crowdfund.currentMoney);
				$("#infoBankCard").html(crowdfund.cardNum + "（" + crowdfund.bankName + "）");
				if (crowdfund.receiptCardNum) {
					$("#infoReceiptBankCard").html(crowdfund.receiptCardNum + "（" + crowdfund.receiptBankName + "）");
				}
				$("#infoUserName").html(crowdfund.username);
				$("#infoAccount").html(crowdfund.userAccount);
				$("#infoBillMoney").html(crowdfund.billMoney);
				
				$("#infoBillImg").html(imgHtml);
				$("#infoBillType").html(billTypeStr);
				$("#infoStartTime").html(toDate(crowdfund.startTime).format('yyyy-MM-dd HH:mm:ss'));
				$("#infoEndTime").html(toDate(crowdfund.endTime).format('yyyy-MM-dd HH:mm:ss'));
				$("#infoStatus").html(statusHtml);
				$("#infoOrderNum").html(crowdfund.orderNum);
				$("#infoServiceMoney").html(crowdfund.serviceMoney);
				$("#infoReason").html(crowdfund.reason);
				$("#infoCreditPoint").html(crowdfund.creditPoint);
				$("#infoCreditReason").html(crowdfund.creditReason);
				$("#infoRejectReason").html(crowdfund.rejectResion);
			}
		});
	}

	function search() {
		totalPages = 0;
		page = 1;
		getCrowdfundMoneyList();
	}

	function goPrevious() {
		if (page > 1) {
			page = page - 1;
			getCrowdfundMoneyList();
		}
	}

	function goNext() {
		if (page < totalPages) {
			page = page + 1;
			getCrowdfundMoneyList();
		}
	}

	function getCrowdfundMoneyList() {
		var searchCrowd = $("#searchCrowd").val();
		var startIndex = (page - 1) * maxCount;

		let url = "/crowdfund/getCrowdfundDetailList";
		let params = {
				"crowdfundId" : crdId,
				"keyWord" : searchCrowd,
				"start" : startIndex,
				"length" : maxCount,
				"draw" : page
		}
		getMapData(url, params, function(data, result) {
			if (result == "success") {
				var dataList = data.data;
				var totalCount = data.recordsTotal;
				if ((totalCount % maxCount) > 0) {
					totalPages = parseInt(totalCount / maxCount) + 1;
				} else {
					totalPages = parseInt(totalCount / maxCount);
				}
				if (page <= 1) {
					$("#pageList .previous").addClass("disabled");
				} else {
					$("#pageList .previous").removeClass("disabled");
				}
				if (page >= totalPages) {
					$("#pageList .next").addClass("disabled");
				} else {
					$("#pageList .next").removeClass("disabled");
				}
				if (totalPages <= 1) {
					$("#pageList").hide();
				}

				var dataHtml = '';
				for (let i = 0; i < dataList.length; i++) {
					let dataRecord = dataList[i];
					let account = dataRecord.acount;
					if (account == "" || account == null) {
						account = "微信用户";
					}
					if (i == 0) {
						dataHtml += '<div class="money-item" style="border-top: 1px solid rgba(0,0,0,.125);">';
					} else {
						dataHtml += '<div class="money-item">';
					}
					dataHtml += '<div class="account">' + account + '</div>';
					dataHtml += '<div class="money text-danger">' + dataRecord.money + '</div>';
					dataHtml += '<div class="time">' + dataRecord.createTime + '</div>';
					dataHtml += '</div>';
				}
				$("#crowdfundMoneyList").html(dataHtml);
				if (totalCount > 0) {
					let startNum = startIndex + 1;
					let endNum = startIndex + dataList.length;
					$("#dataInfo").html('从 ' + startNum + ' 到 ' + endNum + ' /共 ' + totalCount + ' 条数据');
				} else {
					$("#dataInfo").html('没有检索到数据');
				}
			}
		}, true);
	}

</script>
</body>
</html>
